define(function(require){
	var main = require('/static/main.js');
	var m = new main();
	function Cont(){
		this.Fun._init();
	}
	Cont.prototype.Fun = {
		_init:function(){
			this.bindEvent();
		},
		bindEvent:function(){
			var _this = this;
			// 初始化左边菜单
			var param = {
				ReqType:0,
			}
			var sort = 0;
		    var table1 = $('#datatable').dataTable({
	        	'ordering':false,
	        	"serverSide": true,
	        	"searching":false,
	        	'bLengthChange': false,
	        	ajax: function (data, callback, settings) {
	                param.PageSize = data.length;
	                param.start = data.start;
	                param.PageNo = (data.start / data.length)+1;
	                sort = (param.PageNo-1)*param.PageSize;
	                //ajax请求数据
	                $.ajax({
	                    type: "POST",
	                    url: "/analysis/ranking-list",
	                    cache: false,  
	                    data: param,  
	                    dataType: "json",
	                    success: function (result) {
                    	    var returnData = {};
                            returnData.draw = data.draw;
                            returnData.recordsTotal = result.total;
                            returnData.recordsFiltered = result.total;
                            returnData.data = result.data;
                            callback(returnData);
	                    }
	                });
	            },
				"aoColumns":[
					{
						"mDataProp": 'Score',
						render:function(data){
							sort ++;
                    		return sort;
                    	}
					}, 
					{"mDataProp": 'TrueName'}, 
					{
						"mDataProp": 'Photo',
						"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
							$(nTd).html('<img src="'+sData+'" onerror="this.src=\'/modules/img/slefneed/user_default.png\'" style="width:45px;height:45px;border-radius:50%">')
			            }
					}, 
					{"mDataProp": 'Score'}, 
					{"mDataProp": 'CustomerCnt'}, 
				],
	        }).api();
		    $('.nav-tabs li a').click(function(){
		    	var ReqType = parseInt($(this).attr('data-type'));
		    	param.ReqType = ReqType;
		    	table1.ajax.reload();
		    })


		}


	}
	var a = new Cont();

})